import { defineStore } from 'pinia'
import { ref } from 'vue'
import { systemDictApi } from '@/api/system'

export const useSystemStore = defineStore(
  'system',
  () => {
    const dictionary = ref({})

    const setDictionary = async () => {
      const res = await systemDictApi()
      res.data.forEach((e) => {
        dictionary.value[e.code] = JSON.parse(e.itemValues)
      })
    }

    return {
      dictionary,
      setDictionary
    }
  },
  { persist: true }
)
